<?php


namespace App\Http\Controllers\applets\validate;


use Illuminate\Support\Facades\Validator;

class ParentSn
{
    public static function codeGetUsername($param){
        $rules = [
            'randCode'=>'required|numeric'
        ];

        $msg = [
            'randCode.required'=>'邀请码为空',
            'randCode.numeric'=>'邀请码格式不对'
        ];

        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function applyEmpower($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'randCode'=>'required|numeric',
            'snCode'=>'required|between:11,13'
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'randCode.required'=>'邀请码为空',
            'randCode.numeric'=>'邀请码格式不对',
            'snCode.required'=>'sn码为空',
            'snCode.between'=>'sn码长度必须为12位',
        ];

        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function bindParentSn($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'snCode'=>'required|between:11,13',
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'snCode.required'=>'sn码为空',
            'snCode.between'=>'sn码长度必须为12位',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function getEmpower($param){
        $rules = [
            'userId'=>'required|numeric',
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function relieveEmpower($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'id'=>'required|numeric',
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function getFlatIsSuccess($param){
        $rules = [
            'sn'=>'required',
        ];
        $msg = [
            'sn.required'=>'sn码为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function relieveBindParentSn($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'sn'=>'required',
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'sn.required'=>'sn码为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function getSnUid($param){
        $rules = [
            'sn'=>'required',
        ];
        $msg = [
            'sn.required'=>'sn码为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    
}